<script type="text/javascript">
	function calendar_change_question(date_question)
	{
		var post_data = {
			'date_question' : date_question
		};
		$.ajax({
			url: "<?=PATH_URL.'index.php/contest/check_answer_one'?>",
			data: post_data,
			type: 'POST',
			dataType: 'json',
			success: function(data) {
				if(typeof( data.must_ans ) != "undefined"){
					// load ngày phải trả lời trc đó
					// var url = "<?=PATH_URL.'index.php/contest/contest_question_date'?>";
					// $.post(url,{"date_question":data.must_ans},function(data){
						// $('.ajax_question').html("<div style='text-align:center;' class='mt10'>Bạn vui lòng trả lời câu hỏi của các ngày trước để xem bật mí của ngày này là gì nhé</div>" + data);
						// var height_main = $("#main").height();
						// setTimeout('FB.Canvas.setSize({width:810,height:height_main+20})',1000);
					// });
					$('.ajax_question').html("<div style='text-align:center;' class='mt10'>Bạn vui lòng trả lời câu hỏi của các ngày trước để xem bật mí của ngày này là gì nhé</div>");
				} else if(typeof( data.status ) != "undefined"){
					if(data.status == '1'){ 
						// load bai thi ngay
						var url = "<?=PATH_URL.'index.php/contest/contest_question_date'?>";
						$.post(url,{"date_question":date_question},function(data){
							$('.ajax_question').html(data);
							var height_main = $("#main").height();
							setTimeout('FB.Canvas.setSize({width:810,height:height_main+20})',1000);
						});
					}else if(data.status == '2')
					{
						var height_main = $("#main").height();
						$('.ajax_question').html("<div style='text-align:center' class='mt10'>Thông tin đang trong quá trình cập nhật,<br /> bạn vui lòng quay lại sau.</div>");
						setTimeout('FB.Canvas.setSize({width:810,height:height_main+20})',1000);
					}else{
						var height_main = $("#main").height();
						$('.ajax_question').html("<div style='text-align:center;' class='mt10'>Bạn đã hoàn thành xong ngày này do vậy không thể quay lại sửa lại câu trả lời. Vui lòng giải đáp cho các hình/video của các ngày mà bạn chưa hoàn tất</div>");
						setTimeout('FB.Canvas.setSize({width:810,height:height_main+20})',1000);
					}
				}else{
					
				}
			}
		});
	}
</script>
<div class="calendar">
	<div class="top"><a id="tuan_1" class="tuan_1 active" href="#"></a><a id="tuan_2" class="tuan_2" href="#"></a></div>
	<div class="bottom txt_center mt8">
		<div class="list_day" id="tuan_1_day">
		<a href="javascript:void(0);" onclick="return calendar_change_question('2012-12-29');" class="img_day_1 first <?php echo $date_status["2012-12-29"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2012-12-30');" class="img_day_2 <?php echo $date_status["2012-12-30"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2012-12-31');" class="img_day_3 <?php echo $date_status["2012-12-31"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-01');" class="img_day_4 <?php echo $date_status["2013-01-01"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-02');" class="img_day_5 <?php echo $date_status["2013-01-02"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-03');"  class="img_day_6 <?php echo $date_status["2013-01-03"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-04');" class="img_day_7 <?php echo $date_status["2013-01-04"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a></div>
		<div class="list_day" id="tuan_2_day" style="display:none;">
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-05');" class="img_day_8 first <?php echo $date_status["2013-01-05"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-06');" class="img_day_9 <?php echo $date_status["2013-01-06"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-07');" class="img_day_10 <?php echo $date_status["2013-01-07"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-08');" class="img_day_11 <?php echo $date_status["2013-01-08"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-09');" class="img_day_12 <?php echo $date_status["2013-01-09"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-10');" class="img_day_13 <?php echo $date_status["2013-01-10"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" /></a>
		<a href="javascript:void(0);" onclick="return calendar_change_question('2013-01-11');" class="img_day_14 <?php echo $date_status["2013-01-11"];?>"><img src="<?=PATH_URL.'static/images/bg_check_day.png'?>" alt="" class="check png" />
		</a></div>
	</div>
</div>
<div class="ajax_question">
	<?php if(!empty($list_contest)){?>
	<div class="content_home">
		<div class="content_left left">
			<?php if(!empty($list_contest[0])){?>
			<div class="item_large">
			<?php //get_link_img(LINK_CONTEST.$list_contest[1]->image,217,217)?>
				<div style="position:relative;"><a href="#popup_detail_<?=$list_contest[0]->id?>" class="fancybox"><img src="<?=get_link_img(LINK_CONTEST.$list_contest[1]->image,472,340)?>" alt="" class="png" width="472" height="340" /><?php if($list_contest[0]->type == 2){ ?><div class="icon_video_view"></div><?php } ?></a></div>
				<div class="mt10" style="height:96px;"><div><?=$list_contest[0]->description?></div></div>
				<div class="btn_view_more mt15"><a href="#popup_detail_<?=$list_contest[0]->id?>" class="fancybox"><img src="<?=PATH_URL.'static/images/btn_view_more.png'?>" alt="" class="png" /></a></div>
			</div>
			<?php } ?>
			<?php if(!empty($list_contest[1])){?>
			<div class="mt20">
				<div class="item_home left"><a href="#popup_detail_<?=$list_contest[1]->id?>" class="fancybox"><img src="<?=get_link_img(LINK_CONTEST.$list_contest[1]->image,217,217)?>" alt="" class="png"/><?php if($list_contest[1]->type == 2){ ?><div class="icon_video"></div><?php } ?></a><div class="bg_shadow"></div></div>
				<?php } ?>
				<?php if(!empty($list_contest[2])){?>
				<div class="item_home right"><a href="#popup_detail_<?=$list_contest[2]->id?>" class="fancybox"><img src="<?=get_link_img(LINK_CONTEST.$list_contest[2]->image,217,217)?>" width="217" height="217"/><?php if($list_contest[2]->type == 2){ ?><div class="icon_video"></div><?php } ?></a><div class="bg_shadow"></div></div>
				<div class="clearAll"></div>
			</div>
			<?php } ?>
		</div>
		<div class="content_right right">
			<?php if(!empty($list_contest[3])){?>
			<div class="item_home"><a href="#popup_detail_<?=$list_contest[3]->id?>" class="fancybox"><img src="<?=get_link_img(LINK_CONTEST.$list_contest[3]->image,217,217)?>" alt="" class="png" width="217" height="217"/><?php if($list_contest[3]->type == 2){ ?><div class="icon_video"></div><?php } ?></a><div class="bg_shadow"></div></div>
			<?php } ?>
			<?php if(!empty($list_contest[4])){?>
			<div class="item_home mt39"><a href="#popup_detail_<?=$list_contest[4]->id?>" class="fancybox"><img src="<?=get_link_img(LINK_CONTEST.$list_contest[4]->image,217,217)?>" alt="" class="png" width="217" height="217"/><?php if($list_contest[4]->type == 2){ ?><div class="icon_video"></div><?php } ?></a><div class="bg_shadow"></div></div>
			<?php } ?>
			<?php if(!empty($list_contest[5])){?>
			<div class="item_home mt39"><a href="#popup_detail_<?=$list_contest[5]->id?>" class="fancybox"><img src="<?=get_link_img(LINK_CONTEST.$list_contest[5]->image,217,217)?>" alt="" class="png" width="217" height="217"/><?php if($list_contest[5]->type == 2){ ?><div class="icon_video"></div><?php } ?></a><div class="bg_shadow"></div></div>
			<?php } ?>
		</div>
		<div class="clearAll"></div>
	</div>
	<!--popup detail-->
	
	<div style="display:none;">
		<?php 
		if(!empty($list_contest[0]))
		{
		?>
		<div id="popup_detail_<?=$list_contest[0]->id?>" class="popup_detail">
			<?php echo Modules::run('contest/contest_detail',$list_contest[0]->id)?>
		</div>
		<?php 
		}
		?>
		<?php 
		if(!empty($list_contest[1]))
		{
		?>
		<div id="popup_detail_<?=$list_contest[1]->id?>" class="popup_detail">
			<?php echo Modules::run('contest/contest_detail',$list_contest[1]->id)?>
		</div>
		<?php 
		}
		?>
		<?php 
		if(!empty($list_contest[2]))
		{
		?>
		<div id="popup_detail_<?=$list_contest[2]->id?>" class="popup_detail">
			<?php echo Modules::run('contest/contest_detail',$list_contest[2]->id)?>
		</div>
		<?php 
		}
		?>
		<?php 
		if(!empty($list_contest[3]))
		{
		?>
		<div id="popup_detail_<?=$list_contest[3]->id?>" class="popup_detail">
			<?php echo Modules::run('contest/contest_detail',$list_contest[3]->id)?>
		</div>
		<?php 
		}
		?>
		<?php 
		if(!empty($list_contest[4]))
		{
		?>
		<div id="popup_detail_<?=$list_contest[4]->id?>" class="popup_detail">
			<?php echo Modules::run('contest/contest_detail',$list_contest[4]->id)?>
		</div>
		<?php 
		}
		?>
		<?php 
		if(!empty($list_contest[5]))
		{
		?>
		<div id="popup_detail_<?=$list_contest[5]->id?>" class="popup_detail">
			<?php echo Modules::run('contest/contest_detail',$list_contest[5]->id)?>
		</div>
		<?php 
		}
		?>
	</div>
	<?php }else{
		// echo "<div style='text-align:center;' class='mt10'>Bạn vui lòng trả lời câu hỏi của các ngày trước để <br />xem bật mí của ngày này là gì nhé</div>";
	} ?>
</div>
<script type="text/javascript">
	if($('.list_day:visible .active_2').length > 0) {
		$('.list_day:visible .active_2:first').click();
	} else if($('.list_day:visible .active_1').length > 0) {
		$('.list_day:visible .active_1').click();
	} else {
		$('.list_day:visible .active_3').click();
	}
	// calendar_change_question('<?php echo getDateQues();?>');
	var height_main = $("#main").height();
	setTimeout('FB.Canvas.setSize({width:810,height:height_main+20})',1000);
</script>